<!DOCTYPE html>
<html>
<head>
    <title>提问题 {$seo_title} {$site_name}</title>
    <meta name="keywords" content="{$seo_keywords}" />
    <meta name="description" content="{$seo_description}">
    <tc_include file="Public:head" />
    <link href="/themes/simplebootx/Public/assets/css/reset.css" rel="stylesheet"/>
    <link href="/themes/simplebootx/Public/assets/css/sl_style.css?v={$SOURCE_VERSION}" rel="stylesheet"/>
    <style>
        .editor_content {
            position: relative!important;
        }
        .tit input {
            margin-left: 10px!important;
        }
        .put_questions {
            width: 1198px;
        }
        /*行家样式*/
        .answers_expert{
            margin-top: 46px;
            position: relative;
            border: 1px solid #f4f4f4;
            padding: 0 16px 8px;
            box-shadow: 3px 3px 6px 0px
            rgba(0, 0, 0, 0.16);
        }
        .answers_expert .picture_ground {
            width: 60px;
            height: 60px;
            position: absolute;
            top: -30px;
            /*margin-left: 18px;*/

        }
        .answers_expert .picture_ground img {
            width: 100%;
            height: 100%;
            border-radius: 50px;
        }
        .answers_expert .names {
            font-size: 18px;
            font-weight: bolder;
            margin-left: 72px;
            margin-top: -25px;
        }
        .answers_expert .names .name {
            color: #000232;
            line-height: 22px;
            margin-bottom: 4px;
        }
        .answers_expert .names .name2 {
            color: #000232;
            font-size: 14px;
            line-height: 18px;

        }
        .answers_expert .text {
            font-size: 14px;
            color: #707070;
            line-height: 18px;
            margin-top: 18px;
        }
        /*行家样式结束*/
    </style>
</head>
<body>
    <tc_include file="Public:nav" />
    <div class="container tc-main" style="width:1198px;">
        <form action="" method="post" enctype="multipart/form-data" class="form-horizontal js-ajax-forms">
            <div  class="put_questions clearfix">

                <p class="tit" style="width: 1198px;">
                    <input type="text" name="post[post_title]" placeholder="在这里输入问题" style="padding-left: 0px;" >
                </p>

                <div class="leftarea fl" style="width: 760px;margin-top: 80px;">
                    <div class="editor_content">
                        <p class="tit">问题描述：</p>
                        <textarea id="question_show" name="question_show"></textarea>
                        <textarea id="question_content" name="post[post_content]" style="z-index: -1;position:absolute;top: 40px; max-width: 20px;"></textarea>
                    </div>
                    <div class="submit_btn" style="margin-left: 340px;">
                        <p>
                            <span class="submit_btn1">提交</span>
                            <span class="submit_btn2">取消</span>
                        </p>
                    </div>
                </div>


                <php>
                    $professor = get_professor_list();
                </php>
                <if condition="!empty($professor)">
                    <div class="rightarea fr put_sidebar">
                        <div class="author">
                            <div class="sport_ground">
                                <h2>专栏作者</h2>
                            </div>
                            <div class="answers_expert_gronud">
                                <volist name="professor" id="vo">
                                    <a href="{:U('user/index/professor_homepage', array('professor_id' => $vo['user_id']))}" alt="专栏作者" >
                                        <div class="answers_expert">
                                            <div class="picture_ground">
                                                <img src="{:sp_get_user_avatar_url($vo['avatar'])}?t={:time()}" alt="">
                                            </div>
                                            <div class="names">
                                                <p class="name">{$vo.user_nicename|default=$vo['user_login']}</p>
                                                <p class="name2"><span>{$vo.company}</span><span>{$vo.position}</span></p>
                                            </div>
                                            <p class="text">{$vo.signature}</p>
                                        </div>
                                    </a>
                                </volist>
                            </div>
                        </div>
                    </div>
                </if>
            </div>
        </form>
    </div>
    <!-- JavaScript -->
    <tc_include file="Public:scripts" />
    <script type="text/javascript" src="__PUBLIC__/js/artDialog/artDialog.js"></script>
    <script type="text/javascript" src="__PUBLIC__/js/ueditor/ueditor.config.js"></script>
    <script type="text/javascript" src="__PUBLIC__/js/ueditor/ueditor.all.min.js"></script>
    <script type="text/javascript" src="__PUBLIC__/js/layer/layer_1.js"></script>
    <script>
        var loading = false;

        $(function(){

            $('.submit_btn1').click(function () {
                $('form.js-ajax-forms').submit();
            });

            $('.submit_btn2').click(function () {
                window.history.go(-1);
            });

            editorcontent = new baidu.editor.ui.Editor({
                initialFrameWidth   : '100%',   //设置编辑器宽度
                initialFrameHeight  : '320',    //设置编辑器高度
                scaleEnabled        : true,     //设置不自动调整高度
            });
            editorcontent.render('question_show');

            // 监听编辑区内容变化
            editorcontent.addListener( 'selectionchange', function() {
                var content = editorcontent.getContent();
                $('#question_content').val(content); // 方便表单提交验证
            });


            Wind.use('validate', 'ajaxForm', function() {

                var form = $('form.js-ajax-forms');

                //ie处理placeholder提交问题
                if ($.browser && $.browser.msie) {
                    form.find('[placeholder]').each(function() {
                        var input = $(this);
                        if (input.val() == input.attr('placeholder')) {
                            input.val('');
                        }
                    });
                }

                //表单验证开始
                form.validate({
                    //是否在获取焦点时验证
                    onfocusout : false,
                    //是否在敲击键盘时验证
                    onkeyup : false,
                    //当鼠标掉级时验证
                    onclick : false,
                    // 错误展示
                    showErrors : function(errorMap, errorArr) {
                        //errorMap {'name':'错误信息'}
                        //errorArr [{'message':'错误信息',element:({})}]
                        try {
                            $(errorArr[0].element).focus();
                            layer.msg(errorArr[0].message);
                        } catch (err) {

                        }
                        this.defaultShowErrors();
                    },
                    //指明错误放置的位置
                    errorPlacement: function(error, element) {
                    },
                    //验证规则
                    rules : {
                        'post[post_title]' : {
                            required : 1
                        },
                    },
                    //验证未通过提示消息
                    messages : {
                        'post[post_title]' : {
                            required : '请输入问题标题'
                        },
                    },
                    //验证通过，提交表单
                    submitHandler : function(forms) {

                        if (loading) {
                            layer.load();
                            return;
                        }
                        loading = true;

                        $(forms).ajaxSubmit({
                            url : form.attr('action'),
                            dataType : 'json',
                            success : function(data, statusText, xhr, $form) {
                                layer.msg(data.info, { offset: ['47%', '35%'], time : 3000});
                                if (data.status == 1) {

                                    setTimeout(function () {
                                        window.location.href = "{:U('Question/Question/center_question')}" + "&list_index=0";
                                    }, 3000);
                                }
                                loading = false;
                            }
                        });
                    }
                });
            });
        });
    </script>
</body>
</html>